package com.lagado.rrex.app;

import com.lagado.rrex.RRex;

public class Program
{
    public static void main(String[] args)
    {
        RRex ex = RRex.With().Literal("BEGIN!@#%&/.$^{[(|)]}*+?\\END");
        String y = ex.toString();
        String x = "BEGIN!@#%&/\\.\\$\\^\\{\\[\\(\\|\\)]}\\*\\+\\?\\END";
        System.out.printf("%s == %s : %b", x, y, x.equals(y));
        
        RRex socialSecurityNumber = RRex.With().AtBeginning()
            .Digit().Repeat().Exactly(3)
            .Literal("-").Repeat().Optional()
            .Digit().Repeat().Exactly(2)
            .Literal("-").Repeat().Optional()
            .Digit().Repeat().Exactly(4)
            .AtEnd();

        System.out.printf("Social security number: %s \n", socialSecurityNumber);

        String potential1 = "111-22-3344";
        String potential2 = "111-322-3344";
        String potential3 = "111223344";
        System.out.printf("%s: %s \n", potential1, 
                socialSecurityNumber.matches(potential1));
        System.out.printf("%s: %s \n", potential2, 
                socialSecurityNumber.matches(potential2));
        System.out.printf("%s: %s \n", potential3, 
                socialSecurityNumber.matches(potential3));
    }
}
